home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / comm / net / tf02.lha / TinyFugue / tf-lib / tick.tf < prev    next >
Text File  |  1995-08-12  |  1KB  |  47 lines

  1. ;;;; Tick counting
  2. ;;;; This file implements several tick counting commands similar to those
  3. ;;;; found in tintin, useful on Diku muds.  To use, just /load this file.
  4.  
  5. ;;;; usage:
  6. ;;; /tick        Display the time remaining until next tick.
  7. ;;; /tickon        Reset and start the tick counter.
  8. ;;; /tickoff        Stop the tick counter.
  9. ;;; /tickset        Reset and start the tick counter.
  10. ;;; /ticksize <n>    Set the tick length to <n> seconds (default is 75).
  11.  
  12. /~loaded tick.tf
  13.  
  14. /set ticksize=75
  15. /set next_tick=0
  16. /set _tick_pid1=0
  17. /set _tick_pid2=0
  18.  
  19. /def -i tick = \
  20.     /if (next_tick) \
  21.         /eval /echo %%% $$[next_tick - $(/time @)] seconds until tick%;\
  22.     /else \
  23.         /echo %% Tick counter is not running.%;\
  24.     /endif
  25.  
  26. /def -i tickon = \
  27.     /tickoff%;\
  28.     /test next_tick := $(/time @) + ticksize %;\
  29.     /repeat -$[ticksize - 10] 1 \
  30.         /set _tick_pid1=0%%;\
  31.         /echo %%% Next tick in 10 seconds.%;\
  32.         /set _tick_pid1=%?%;\
  33.     /repeat -%ticksize 1 \
  34.         /set _tick_pid2=0%%;\
  35.         /echo %%% TICK%%;\
  36.         /tickon%;\
  37.     /set _tick_pid2=%?
  38.  
  39. /def -i tickoff = \
  40.     /test _tick_pid1 & (kill(_tick_pid1), _tick_pid1:=0)%;\
  41.     /test _tick_pid2 & (kill(_tick_pid2), _tick_pid2:=0)%;\
  42.     /set next_tick=0
  43.  
  44. /def -i tickset    = /tickon %*
  45.  
  46. /def -i ticksize    = /set ticksize %*
  47.